<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>客户跟进</title>
    <link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/news/center.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="../../lib/layui-v1.0.9_rls/layui/css/layui.css">
    <script type="text/javascript" src="../../js/news/jquery-1.9.1.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="../../js/news/page.js"></script>
    <script type="text/javascript" src="../../lib/layui-v1.0.9_rls/layui/lay/dest/layui.all.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/layer/layer.js?20201106"></script>
    <script src="../../lib/laydate/laydate.js"></script>
    <style>
        * {font-family: "Microsoft Yahei" !important;}
        body{
            width: 100%;
            margin:0 auto;
        }
        b{
            color: red;
        }
        .head_title{
            margin-top: 10px;
            height: 40px;
            position: relative;
        }
        .head_title .title{
            margin-left: 22px;
        }
        .head_title span{
            float: none;
            /*margin-top: 9px;*/
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }
        .saveBtn{
            display: block;
            float: left;
            background: url(../img/confirm.png) no-repeat;
            border: none;
            width: 70px;
            height: 29px;
            line-height: 29px;
            margin-left: 10px;
            cursor: pointer;
        }
        .resetBtn {
            display: block;
            float: left;
            background: url(../img/news/new_filling.png) no-repeat;
            border: none;
            width: 70px;
            height: 29px;
            line-height: 29px;
            margin-left: 10px;
            cursor: pointer;
        }
        .div_Btn{
            position: absolute;
            margin: 10px auto;
            left: 42%;
        }
        select{
            width: 250px;
            height: 30px;
        }
        .newTbale tr td {
            border-right: #ccc 1px solid;
            padding: 5px 30px;
        }
        input[type="text"]{
            width: 250px;
            height: 30px;
        }
        .newTbale {
            width: 85%;
            margin: 0px auto;
        }
        table {
            border-collapse: collapse;
            border-spacing: 0;
        }
        #ajaxforms{
            position: relative;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>
<!--head开始-->
<div class="head_title">
    <div class="title">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png"><span style="">客户跟进</span>
    </div>
</div>
<div id="pagediv">
    <form id="ajaxforms" action="/customer/updateWorkbench">
        <table class="newTbale">
            <tr>
                <td>客户名称:</td>
                <td><input type="text" name="customerName" readonly="readonly" disabled="true"/><b>*</b></td>
                <td>跟进方式:</td>
                <td>
                    <select name="followType" >
                        <option value="">请选择跟进方式</option>
                    </select>
                    <b>*</b>
                </td>
            </tr>
            <tr>
                <td>跟进地点:</td>
                <td><input type="text" name="address"/></td>
                <%-- <td>跟进时间:</td>
                 <td><input type="text" name="followTime" /></td>--%>
                <td>跟进情况:</td>
                <td><input type="text" name="followSituation" /></td>
            </tr>
            <tr>
                <td>需求反馈:</td>
                <td><input type="text" name="feedback" /></td>
                <td>创建人:</td>
                <td><input type="text" name="creatorNew" disabled="true"/></td>
            </tr>
            <tr>
                <td>创建时间:</td>
                <td><input type="text" disabled="true" name="creatorTimeNew"  placeholder="请输入时间" id="startTimeOne" onclick="laydate(starts)" /></td>
                <td>联系人姓名:</td>
                <td><input type="text" name="linkmanName" disabled="true"/></td>
            </tr>
            <%--<tr>--%>
            <%--<td>联系人职务:</td>--%>
            <%--<td><input type="text" name="job" disabled="true"/></td>--%>
            <%--&lt;%&ndash;<td>联系人QQ:</td>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<td colspan="3" ><input type="text" name="qq" disabled="true"/></td>&ndash;%&gt;--%>
            <%--</tr>--%>
            <%--<tr>--%>
            <%--<td>联系人性别:</td>--%>
            <%--<td >--%>
            <%--<input type="radio" name="sex" checked="checked"  id="male" value="0" disabled="true"/>男--%>
            <%--<input type="radio" name="sex"  id="woman" value="1" disabled="true"/>女--%>
            <%--</td>--%>
            <%--<td>首选联系方式:</td>--%>
            <%--<td disabled="true">--%>
            <%--&lt;%&ndash;<select name="firstContact"  disabled="true">--%>
            <%--<option value="">请选择联系方式</option>--%>
            <%--</select>--%>
            <%--<b>*</b>&ndash;%&gt;--%>
            <%--<input type="text" name="firstContact" disabled="true"/>--%>
            <%--</td>--%>
            <%--</tr>--%>
            <%--<tr>--%>
            <%--<td>联系人手机:</td>--%>
            <%--<td><input type="text" name="mobile" disabled="true"/></td>--%>
            <%--<td>联系人邮箱:</td>--%>
            <%--<td><input type="text" name="email" disabled="true"/></td>--%>
            <%--</tr>--%>

        </table>

    </form>
</div>
<div class="div_Btn">
    <div class="saveBtn">
        <span  onclick="ajaxforms()" style="margin-left: 32px;">保存</span>
    </div>
    <div class="resetBtn" onclick="javascript:window.location.href='/customer/salesWorkbench';">
        <span  style="margin-left: 32px;" >返回</span>
    </div>
</div>
</body>
<script>
    var getRequestObj=$.GetRequest();
    function GetDropDownBox(fn) {
        $.ajax({
            url: "/customer/selectByType",
            type: 'get',
            dataType: "JSON",
            success: function (data) {
                var str = '<option value="">请选择跟进方式</option>';
                for (var i = 0; i < data.obj.length; i++) {
                    str += '<option value="' + data.obj[i].codeNo + '">' + data.obj[i].codeName + '</option>'
                }
                $('[name="followType"]').html(str);
            }
        })
        $.ajax({
            url: "/customer/selectByType",
            type:'get',
            dataType:"JSON",
            success:function(data){
                var str='<option value="">请选择首选联系方式</option>';
                for (var i=0;i<data.obj.length;i++){
                    str += '<option value="'+data.obj[i].codeNo+'">'+data.obj[i].codeName+'</option>'
                }
                $('[name="firstContact"]').html(str);
            }
        })
    }
    //        修改数据
    function  ajaxforms() {
        if($('[name="followType"] option:selected').val() == ''){
            layer.msg('请选择跟进方式 ！',{icon:6});
        }else {
            $.ajax({
                url: '/customer/insertFollow',
                type: 'post',
                dataType: 'json',
                data: $('#ajaxforms').serialize()+'&customerId='+getRequestObj.customerId,
                success: function (data) {
                    if(data.flag){
                        layer.msg('跟进成功！',{icon:1},function () {
                            window.close();
                            window.location.href='/customer/salesWorkbench'
                        });/*添加成功*/
                    }else{
                        layer.msg('跟进失败！',{icon:2});/*添加失败*/
                    }
                },
                error: function (data) {
                    layer.msg('跟进失败！',{icon:2});/*添加失败*/
                }
            })
        }

    }
    //数据回显
    $(function () {

        GetDropDownBox(function(){
            $('[name="firstContact"]').val(getRequestObj.codeNo);
        });

        $.ajax({
            url:'/linkMan/selectcustomerByLId',
            data:{
                customerId:getRequestObj.customerId
            },
            type: 'get',
            dataType: 'json',

            success:function (json) {
                var firstContact;
                if(json.object.firstContact == "01"){
                    var firstContact = '电话'
                }else if(json.object.firstContact == "02"){
                    var firstContact = '短信'
                }else if(json.object.firstContact == "03"){
                    var firstContact = '微信'
                }else if(json.object.firstContact == "04"){
                    var firstContact = 'QQ'
                }else if(json.object.firstContact == "05"){
                    var firstContact = '会面'
                }
                if (json.flag) {
                    $('[name="customerName"]').val(json.object.customerName);
                    $('[name="creatorNew"]').val(json.object.creatorNew);
                    $('[name="creatorTimeNew"]').val(json.object.creatorTimeNew);
                    $('[name="linkmanName"]').val(json.object.linkmanName);
                    $('[name="firstContact"]').val(firstContact);
                    $('[name="job"]').val(json.object.job);
                    $('[name="mobile"]').val(json.object.mobile);
                    $('[name="email"]').val(json.object.email);
                    $('[name="wechat"]').val(json.object.wechat);
                    $('[name="qq"]').val(json.object.qq);
                    if(json.object.sex==0){
                        $('#male').attr("checked",true)
                    }else{
                        $('#woman').attr("checked",true)
                    }

                }
            }
        })

    })
</script>

</html>
